﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Cit.CDE.Net.Module;
using Cit.CDE.Net.Module.Commons;
using cde.SystemCommon;
using ConfigAndElse;
using System.Text;
using cde.UserControl;
using System.IO;
using System.Xml;
using Module;
using Cit.CDE.Net.Service.ModuleFactory;
using Cit.CDE.Net.Service;
using UserControl;
using System.Timers;
using System.Data.SqlClient;
using Cit.CDE.ApplicationBlocks.Data;
using Cit.CDE.Net.Service.DataAccess;
using System.Reflection;
using System.Net.Mail;

/// <summary>
/// FileName:       Business_Detail.ascx
/// Author :         wangbc
/// CDT:             2013-8-5           
/// Version:         1.0.0.0                
/// Depiction:       商机详细
/// </summary>
public partial class main_UserControls_Business_Detail_View : UserControl.UserControlsCommon
{
    /// <summary>
    /// EntityManager
    /// </summary>
    private CDEEntityManager em;
    /// <summary>
    /// 查询条件
    /// </summary>
    private  CDESearchCriteria sc;

    private CDEEntity m_entity;
    private string p_id;
    protected void Page_Load(object sender, EventArgs e)
    {
        HiddenField hd = (HiddenField)this.Parent.FindControl("BS_ID");
        p_id = hd.Value;
        if (!IsPostBack)
        {
          
        }
      
        if (p_id == "")
        {
            p_id = "0";
        }
        this.bindDataByID(p_id);
        this.bindFollowDataByID(p_id);
        
    }
     
    /// <summary>
    /// 数据绑定样式
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dgmeisai_ItemDataBound(object sender, DataGridItemEventArgs e)
    {       
        int index = e.Item.ItemIndex;
        if (index == -1 || dgmeisai.ListEntity == null || dgmeisai.ListEntity.Count < index) return;
        e.Item.Attributes.Add("style","text-align :center");
        //设置鼠标滑动效果
        if (index % 2 == 0)
        {
            e.Item.Attributes.Add("class", "bgtr2");
            e.Item.Attributes.Add("onmouseover", "this.className='bgtr3'");
            e.Item.Attributes.Add("onmouseout", "this.className='bgtr2'");
        }
        else
        {
            e.Item.Attributes.Add("class", "bgtr1");
            e.Item.Attributes.Add("onmouseover", "this.className='bgtr3'");
            e.Item.Attributes.Add("onmouseout", "this.className='bgtr1'");
        }
    }

    /// <summary>
    /// 绑定页面数据
    /// </summary>
    public void bindDataByID(string pre_id)
    {
        em = CDEEMFactory.getEMByFullName(WEBConstants.EM_BUSINESS_DETAILS_MANAGE);
        sc = new CDESearchCriteria(em);
        sc.addCondition("BS_ID", pre_id);
        List<CDEEntity> list = CDEService.LoadEntities(em, sc);
        if (this.dgmeisai.Columns.Count > 1)
        {
            DataGridColumn col = this.dgmeisai.Columns[this.dgmeisai.Columns.Count-1];
            this.dgmeisai.Columns.Clear();
            col.HeaderStyle.Width = 100;
            col.ItemStyle.Width = 100;
            this.dgmeisai.Columns.Add(col);         
        }        
        this.dgmeisai.EntityManager = em;       
        this.dgmeisai.ListEntity = list;
        this.dgmeisai.DataBind();       
    }


    /// <summary>
    /// 绑定商机跟进页面数据
    /// </summary>
    public void bindFollowDataByID(string pre_id)
    {
        em = CDEEMFactory.getEMByFullName(WEBConstants.EM_BUSINESS_FOLLOW_MANAGE);
        sc = new CDESearchCriteria(em);
        sc.addCondition("BS_ID", pre_id);
        List<CDEEntity> list = CDEService.LoadEntities(em, sc);
        if (this.SimpleResultDataGrid1.Columns.Count > 1)
        {
            DataGridColumn col = this.SimpleResultDataGrid1.Columns[this.SimpleResultDataGrid1.Columns.Count - 1];
            this.SimpleResultDataGrid1.Columns.Clear();
            col.HeaderStyle.Width = 100;
            col.ItemStyle.Width = 100;
            this.SimpleResultDataGrid1.Columns.Add(col);
        }
        this.SimpleResultDataGrid1.EntityManager = em;
        this.SimpleResultDataGrid1.ListEntity = list;
        this.SimpleResultDataGrid1.DataBind();
    } 
     
}
